<?php
class Users_model extends CI_Model {
    function __construct()
    {
        parent::__construct();
        $this->load->database();
    }
    function insert_row($aUsername,$aEmail)
    {
        $sql = "INSERT INTO users(name, email, created_at) VALUES (\"$aUsername\",\"$aEmail\",now())";
        $this->db->query($sql);
    }
    function check_duplicates($aEmail)
    {
        //SELECT * FROM `users` WHERE `email`='c'
        $query = $this->db->query("SELECT * FROM `users` WHERE `email`=\"$aEmail\"");
        if ($query->num_rows() == 0)
        {
            return false;
        }
        return true;
    }
    function check_if_login_ok($aUser,$aPassword)
    {
    	$query = $this->db->query("SELECT * FROM `users` WHERE `name`=\"$aUser\" and `password`=\"$aPassword\" ");
    	if ($query->num_rows() != 0)
    	{
    		return true;
    	}
    	return false;
    
    }
}
?>